public class Image{
 
  PImage anImage;
  int duration, startTime, previousUpdate;
  float currentTint = 0, endingTint, tintIncrement;//
  PVector location;
  boolean hasTimeExpired = false;
  
  public Image(PImage anImage, PVector location, float startingTint, float endingTint, float tintIncrement){
    this.anImage = anImage;
    this.location = location;
    this.previousUpdate = millis();
    duration = 10000;
    startTime = millis();
    currentTint = startingTint;
    this.endingTint = endingTint;
    this.tintIncrement = tintIncrement;
  }
  
  void setDurationOfImage(int duration){
    this.duration = duration;
  }
  
  public boolean hasTimeExpired(){
   return hasTimeExpired; 
  }
  
  public void drawImageWithFadeInTint(int currentTime){
      if(currentTint <= endingTint){
        currentTint += tintIncrement; 
      } else {
        hasTimeExpired  = true;
      }
      //imageMode(CENTER);
      tint(255, 255, 255, currentTint);
      image(anImage, location.x, location.y);
     // imageMode(CORNER);
      noTint();
  }
  
  public void drawImageWithFadeOutTint(int currentTime){
      if(currentTint >= endingTint){
        currentTint -= tintIncrement; 
      } else {
        hasTimeExpired  = true;
      }
     // imageMode(CENTER);
      tint(255, 255, 255, currentTint);
      image(anImage, location.x, location.y);
     // imageMode(CORNER);
      noTint();
  }
  
  public void drawImageWithNoTint(){
  // imageMode(CENTER);
   image(anImage, location.x, location.y);
  // imageMode(CORNER) ;
  }
}
  
 
  
  
